﻿using FluentValidation;
using SDF.Admin.Models.Catalog;
using SDF.Core.Domain.Catalog;
using SDF.Data;
using SDF.Services.Localization;
using SDF.Web.Framework.Validators;

namespace SDF.Admin.Validators.Catalog
{
    public partial class ProductReviewValidator : BaseSDFValidator<ProductReviewModel>
    {
        public ProductReviewValidator(ILocalizationService localizationService, IDbContext dbContext)
        {
            RuleFor(x => x.Title).NotEmpty().WithMessage(localizationService.GetResource("Admin.Catalog.ProductReviews.Fields.Title.Required"));
            RuleFor(x => x.ReviewText).NotEmpty().WithMessage(localizationService.GetResource("Admin.Catalog.ProductReviews.Fields.ReviewText.Required"));

            SetStringPropertiesMaxLength<ProductReview>(dbContext);
        }
    }
}